program Rectangles;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type
   Rectangle = class
     public
       a, b: integer;
       procedure Square; virtual;
       procedure Update;
     private
       s: integer;
     end;

   SmartRectangle = class (Rectangle)
     public
       procedure Square; override;
       procedure SetS (numa, numb: integer);
     private
     end;
{ Rectangle }

procedure Rectangle.Square;
begin
  writeln (s);
end;

procedure Rectangle.Update;
begin
  s:=a*b;
end;

{ SmartRectangle }

procedure SmartRectangle.SetS(numa, numb: integer);
begin
  a:=numa;
  b:=numb;
  s:=a*b;
end;

procedure SmartRectangle.Square;
begin
  if (s<>a*b) then writeln ('Square is not actual');
  writeln (s);
end;

var
  r: Rectangle;
  sr: SmartRectangle;
  a, b: integer;
begin
  r:= Rectangle.Create;
  sr:= SmartRectangle.Create;
  readln (r.a, r.b);
  r.Update;
  r.Square;
  readln (a,b);
  sr.SetS(a, b);
  sr.Square;
  sr.a:=sr.a-1;
  sr.b:=sr.b+1;
  sr.Square;
  sr.Update;
  sr.Square;
  readln;
end.
 